﻿using Net.Sz.Framework.Netty.Http;
using Net.Sz.Framework.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;


namespace CApp_CheckLoginTps
{

    class Program
    {

        static List<int> idList = new List<int>();
        static IntegerSSId ids = new IntegerSSId();

        static void Main(string[] args)
        {
            Console.WriteLine("准备就绪");
            while (true)
            {
                Console.ReadLine();
                Console.WriteLine("注册登录");
                test();
                Console.ReadLine();
                Console.WriteLine("缓存登录");
                test2();
            }
            Console.ReadLine();
        }


        static void test()
        {
            Program.idList.Clear();
            int tcount = 10;
            for (int i = 1; i <= tcount; i++)
            {
                new Thread(() =>
                {
                    System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                    watch.Start();
                    int id = ids.GetId();
                    Program.idList.Add(id);
                    string ret = HttpClient.UrlGet("http://192.168.2.235:7073/login?platform=100&channel=100&username=" + (id) + "&password=1&version=1&mac64=jdjdjjd&os=ios&fr=0202125");
                    watch.Stop();
                    Console.WriteLine(watch.ElapsedMilliseconds);
                }).Start();
            }
        }

        static void test2()
        {
            int tcount = Program.idList.Count;

            for (int i = 0; i < tcount; i++)
            {
                new Thread(new ParameterizedThreadStart((object obj) =>
                {
                    System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
                    watch.Start();
                    string ret = HttpClient.UrlGet("http://192.168.2.235:7073/login?platform=100&channel=100&username=" + (obj) + "&password=1&version=1&mac64=jdjdjjd&os=ios&fr=0202125");
                    watch.Stop();
                    Console.WriteLine(watch.ElapsedMilliseconds);
                })).Start(Program.idList[i]);
            }
        }
    }

}
